/*******************************************************************************
 * Copyright 2013 Mindaugas Idzelis
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package incontrol.bf3.protocol.events;

public enum EventType {
	// @formatter:off
	PLAYER_AUTH("player.onAuthenticated"),
	PLAYER_JOIN("player.onJoin"),
	PLAYER_LEAVE("player.onLeave"),
	PLAYER_SPAWN("player.onSpawn"),
	PLAYER_KILL("player.onKill" ),
	PLAYER_CHAT("player.onChat"),
	PLAYER_SQUADCHANGE("player.onSquadChange"),
	PLAYER_TEAMCHANGE("player.onTeamChange" ),
	PUNKBUSTER("punkBuster.onMessage" ),
	SERVER_LEVELLOADED("server.onLevelLoaded" ),
	SERVER_ROUNDOVER("server.onRoundOver"),
	SERVER_ROUNDOVERPLAYERSTATS("server.onRoundOverPlayers"),
	SERVER_ROUNDOVERTEAMSTATS("server.onRoundOverTeamScores" ), 
	UNKNOWN("" );
	// @formatter:on
	private String command;

	private EventType(String command) {
		this.command = command;
	}

	public String getCommand() {
		return command;
	}

	public static EventType lookup(String cmdId) {
		String command = cmdId;
		for (EventType etype : EventType.values()) {
			String cmd = etype.getCommand();

			if (cmd.equals(command)) {
				return etype;
			}
		}
		return EventType.UNKNOWN;
	}
}
